function showLoginForm() {
	var form = document.getElementById("login_background");

	if (document.all) {
		var display=form.currentStyle.display;
		var formHeight=form.currentStyle.height;
	} else {
		var display = document.defaultView.getComputedStyle(form, "").getPropertyValue("display");
		var formHeight = document.defaultView.getComputedStyle(login_form_centering, "").getPropertyValue("height");
	}
	var childs = document.getElementById("social_buttons").childNodes;
	var summ = 0;

	if(formHeight == "460px") {
		for (var i = 0; i < childs.length; i++) {
			if (childs[i].tagName === "BUTTON")
			summ += 47;
		}
		document.getElementById('login_form_centering').style.height = parseInt(formHeight) - 84 + summ + 'px';
	}

	if (display === "none") {
		form.style.display = "block";
	} else {
		form.style.display = "none";
	}
}

function showSocialButtons()
{
	var openBtn=document.getElementById("form_circle");
	var displayBtns=document.getElementById("showing_container");
	var classWord=openBtn.className;
	var childs=document.getElementById("social_buttons").childNodes;
	var summ=2;

	for (var i=0;i<childs.length;i++)
	{
		if (childs[i].tagName==="BUTTON")
		summ+=50;
	}
	if (classWord==="circle_off")
	{
		openBtn.className="circle_on"
		var step=0;
		var interval=setInterval(function(){if(step<summ)
		{
		step+=5;
		displayBtns.style.height=step+"px";
		}
		else
		{
		clearInterval(interval);
		}
		},15)
	}
	else
	{
		openBtn.className="circle_off"
		var step=summ;
		var interval=setInterval(function(){if(step>=0)
		{
		step=step-5;
		displayBtns.style.height=step+'px';
		}
		else
		{
		displayBtns.style.height=0+'px';
		clearInterval(interval);
		}
		},15)
	}
}

document.onclick=formOpenning;
function formOpenning(e){
	if (e == null) e = window.event;
	var target = e.target != null ? e.target : e.srcElement;
	if (document.all) var clasName=target.className.split(" ")[0];
	else var clasName=target.className;

	if (clasName=="content_atsauksme_button") {

		var parent=target.parentNode;
		var children=parent.childNodes;
		for (var i=0; i<children.length;i++)
		{

			if(children[i].className=="comment_submit_form_showing")
			{
			var showing=children[i];
			}
		}

		if (document.all)
		{
		var showHeight=showing.currentStyle.height;
		}
		else
		{
		var showHeight=document.defaultView.getComputedStyle(showing,"").getPropertyValue("height");
		}
		var intHeight=showHeight.substring(0,showHeight.length-2);

		if(parseInt(showHeight)==0)
		{
			var step=0;
			var interval=setInterval(function(){if(step<168)
			{
			step+=5;
			showing.style.height=step+"px";
			}
			else
			{
			clearInterval(interval);
			}
			},10)
			target.innerHTML=CORE.Lang("close");
		} else {
			var step=168;
			var interval=setInterval(function(){if(step>=5)
			{
			step=step-5;
			showing.style.height=step+'px';
			}
			else
			{
			showing.style.height=0+'px';
			clearInterval(interval);
			}
			},10)
		    if (parent.id=="aprikojuma_katalogs_tab_content_atsauksme_add")
			target.innerHTML=CORE.Lang("add");
			else
			target.innerHTML=CORE.Lang("answer");
		}
	}
}

$('#login_form_click').click(
	function () {
		showLoginForm();
		return false;
	}
);
$('#login_form_closing').click(
	function () {
		showLoginForm();
	}
);

$('#form_circle').click(
	function () {
		showSocialButtons();
	}
);